home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / misc / wexmast / wlabtext.pro < prev    next >
Text File  |  1997-07-08  |  3KB  |  113 lines

  1. ; $Id: wlabtext.pro,v 1.3 1997/01/15 04:29:15 ali Exp $
  2. ;
  3. ; Copyright (c) 1993-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5.  
  6. ; This is the code for a labeled text field.
  7.  
  8. ; This example shows a common combination of widgets where
  9. ; A label is right next to a text field.  In this example, 
  10. ; A label that says 'Name: ' is right next to an editable text
  11. ; widget.  When some text is entered in the name field, it
  12. ; is echoed to a 'Message: ' field. 
  13.  
  14.  
  15.  
  16. PRO wlabtext_event, event
  17. ; This is the event handler for a text widget with a label.
  18.  
  19. ; Because the widget ID for the message field is needed in the CASE
  20. ; statement below, 'message' is put in a COMMON block:
  21.  
  22. COMMON wlabtextblock, message
  23.  
  24. ; Get the widget ID of any widget touched and put it into 'eventval'.
  25. ; Pressing the RETURN key inside a text widget generates an event:
  26.  
  27. WIDGET_CONTROL, event.id, GET_UVALUE = eventval
  28.  
  29. ; Perform different actions based upon 'eventval':
  30.  
  31. CASE eventval OF
  32.     "NAME"    : BEGIN
  33.  
  34.           ;A RETURN has been pressed in the Name field
  35.           ;so get the value of the Name field, and print
  36.           ;it in the Message field:
  37.  
  38.                 WIDGET_CONTROL, event.id, GET_VALUE = newname
  39.           stuff = newname + ' was entered in the name field.'
  40.           WIDGET_CONTROL, message, SET_VALUE = stuff
  41.  
  42.           END
  43. ENDCASE
  44.  
  45. END
  46.  
  47.  
  48.  
  49. PRO wlabtext, GROUP = GROUP
  50. ; This is the procedure for a text widget with a label.
  51.  
  52. ; The widget ID for the message field will be needed in the procedure
  53. ; above, so put 'message' in a COMMON block:
  54.  
  55. COMMON wlabtextblock, message
  56.  
  57. ; This is the procedure that creates a simple label widget.
  58.  
  59. base = WIDGET_BASE(TITLE = 'Example Label/Text Widget', $
  60.            /COLUMN)    ;Organize subsequent widgets in columns.
  61.  
  62.  
  63. ; Make a ROW base widget so the label and text field can be
  64. ; side by side:
  65.  
  66. row1 = WIDGET_BASE(base, /ROW, /FRAME)
  67.  
  68.  
  69. ; Put the name field label into the row base first:
  70.  
  71. namelabel = WIDGET_LABEL(row1, $        ;This label belongs to row1.
  72.                  VALUE = 'Name:')    ;The value of the label.
  73.  
  74.  
  75. ; Then put the name field text widget into the row base:
  76.  
  77. name = WIDGET_TEXT(row1, $             ;This widget belongs to row1.
  78.            /EDITABLE, $            ;Make the text field editable.
  79.            XSIZE = 30, $
  80.            YSIZE = 1, $
  81.            UVALUE = 'NAME')        ;The User Value for the widget.
  82.  
  83. ; Make another ROW base to hold another label and text field:
  84.  
  85. row2 = WIDGET_BASE(base, /ROW, /FRAME)
  86.  
  87. ; Put the message field label into the 2nd row base:
  88.  
  89. messlabel = WIDGET_LABEL(row2, $
  90.                  VALUE = 'Message: ')
  91.  
  92. ; Then put the message text widget into the 2nd row base.
  93. ; Note that this text widget is NOT editable:
  94.  
  95. message = WIDGET_TEXT(row2, $
  96.               VALUE = 'Enter a name in the space above and press RETURN.', $
  97.               XSIZE = 90, $
  98.               YSIZE = 1, $
  99.               UVALUE = 'MESSAGE')
  100.  
  101.  
  102. ; Realize the widgets:
  103. WIDGET_CONTROL, base, /REALIZE
  104.  
  105. ; Hand off to the XMANAGER:
  106. XMANAGER, 'wlabtext', base, GROUP_LEADER = GROUP, /NO_BLOCK
  107.  
  108. END
  109.  
  110.  
  111.  
  112.  
  113.